package com.Maykk.charStream;

import java.io.*;

/**
 * @ClassName: Demo05
 * @Description: TODO 用字符流复制文件
 * @Author: MaykkStar@163.com
 */
public class Demo05 {
    public static void main(String[] args) throws IOException {
        final String SRC = "./Maykk.txt";
        final String TO = "./MaykkNew.txt";
        // 定义字符输入流
        InputStreamReader ir = new InputStreamReader(new FileInputStream(SRC));
        // 定义字符输出流
        OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream(TO));

        // 复制文件
        char[] chars = new char[1024];
        int len;
        while ((len = ir.read(chars)) != -1) {
            ow.write(chars, 0, len);
            ow.flush();  // 手动刷新流
        }

        // 关闭流
        ir.close();
        ow.close();
    }
}
